Reveal sidebar projects from command palette#3211
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Reveal abort leaves pending request
- Replaced the single requestAnimationFrame with a retry loop (up to 20 frames) so the effect keeps trying until projectHeaderRef is available and the reveal completes.
- ✅ Fixed: Unstable complete callback resets reveal
- Wrapped requestSidebarProjectReveal and completeSidebarProjectReveal in useCallback to stabilize their identity across renders, preventing the effect from being torn down and rescheduled on every parent re-render.
Or push these changes by commenting:
@cursor push 4501ba47ce
Preview (4501ba47ce)
diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx
--- a/apps/web/src/components/CommandPalette.tsx
+++ b/apps/web/src/components/CommandPalette.tsx
@@ -376,18 +376,18 @@
const nextSidebarProjectRevealRequestIdRef = useRef(0);
const [sidebarProjectRevealRequest, setSidebarProjectRevealRequest] =
useState<SidebarProjectRevealRequest | null>(null);
- function requestSidebarProjectReveal(projectRef: ScopedProjectRef): void {
+ const requestSidebarProjectReveal = useCallback((projectRef: ScopedProjectRef): void => {
nextSidebarProjectRevealRequestIdRef.current += 1;
setSidebarProjectRevealRequest({
requestId: nextSidebarProjectRevealRequestIdRef.current,
projectRef,
});
- }
- function completeSidebarProjectReveal(requestId: number): void {
+ }, []);
+ const completeSidebarProjectReveal = useCallback((requestId: number): void => {
setSidebarProjectRevealRequest((current) =>
current?.requestId === requestId ? null : current,
);
- }
+ }, []);
const routeTarget = useParams({
strict: false,
select: (params) => resolveThreadRouteTarget(params),
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1179,17 +1179,31 @@
return;
}
- const frame = window.requestAnimationFrame(() => {
+ const revealId = projectRevealRequestId;
+ let cancelled = false;
+ let frameId: number;
+ let attempts = 0;
+ const maxAttempts = 20;
+
+ function tryScroll() {
+ if (cancelled) return;
const projectHeader = projectHeaderRef.current;
- if (!projectHeader) {
+ if (projectHeader) {
+ scrollSidebarProjectIntoView(projectHeader);
+ completeProjectReveal(revealId);
return;
}
- scrollSidebarProjectIntoView(projectHeader);
- completeProjectReveal(projectRevealRequestId);
- });
+ attempts++;
+ if (attempts < maxAttempts) {
+ frameId = window.requestAnimationFrame(tryScroll);
+ }
+ }
+ frameId = window.requestAnimationFrame(tryScroll);
+
return () => {
- window.cancelAnimationFrame(frame);
+ cancelled = true;
+ window.cancelAnimationFrame(frameId);
};
}, [completeProjectReveal, projectRevealRequestId]);
const sidebarThreads = useThreadShellsForProjectRefs(project.memberProjectRefs);You can send follow-ups to the cloud agent here.
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (sidebar project reveal from command palette) with unresolved review comments identifying potential bugs in the implementation. New features adding user-facing behavior warrant human review. You can customize Macroscope's approvability policy. Learn more. |
22cb345 to
81bed8f
Compare
- Track sidebar project reveal requests with request ids - Scroll the matching project row into view after opening - Stabilize reveal callbacks and tolerate delayed project row mounts - Add resolver tests for grouped and ungrouped project rows Co-authored-by: codex <codex@users.noreply.github.com>
81bed8f to
d6693a8
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Reveal requests never complete
- Added a parent-level useEffect that auto-completes reveal requests after a 2-second timeout when the target project key can't be resolved or when the settings page is active, preventing indefinitely pending requests.
- ✅ Fixed: Mobile reveal stays hidden
- Added a useEffect that calls setOpenMobile(true) when a projectRevealTarget is active on mobile, ensuring the sidebar sheet opens so the scroll-into-view logic can run and be visible.
Or push these changes by commenting:
@cursor push 12064e28b4
Preview (12064e28b4)
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -3186,6 +3186,34 @@
projectRevealKey && sidebarProjectRevealRequest
? { projectKey: projectRevealKey, requestId: sidebarProjectRevealRequest.requestId }
: null;
+
+ // Auto-complete reveal requests that no SidebarProjectItem can fulfil:
+ // - projectRevealTarget is null (project key couldn't be resolved)
+ // - isOnSettings is true (project list replaced by SettingsSidebarNav)
+ // A short delay allows async navigation or data hydration to settle first.
+ useEffect(() => {
+ if (!sidebarProjectRevealRequest) return;
+ if (projectRevealTarget && !isOnSettings) return;
+
+ const timer = window.setTimeout(() => {
+ completeSidebarProjectReveal(sidebarProjectRevealRequest.requestId);
+ }, 2_000);
+
+ return () => window.clearTimeout(timer);
+ }, [
+ sidebarProjectRevealRequest,
+ projectRevealTarget,
+ isOnSettings,
+ completeSidebarProjectReveal,
+ ]);
+
+ // On mobile, open the sidebar sheet so the reveal scroll is visible.
+ useEffect(() => {
+ if (isMobile && projectRevealTarget) {
+ setOpenMobile(true);
+ }
+ }, [isMobile, projectRevealTarget, setOpenMobile]);
+
const sidebarThreadByKey = useMemo(
() =>
new Map(You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit d6693a8. Configure here.
| const projectRevealTarget = | ||
| projectRevealKey && sidebarProjectRevealRequest | ||
| ? { projectKey: projectRevealKey, requestId: sidebarProjectRevealRequest.requestId } | ||
| : null; |
There was a problem hiding this comment.
Reveal requests never complete
Medium Severity
The project reveal mechanism can leave requests pending indefinitely. This happens if the target project isn't found, or if the sidebar component responsible for completing the reveal unmounts before it can execute.
Reviewed by Cursor Bugbot for commit d6693a8. Configure here.
| const projectRevealTarget = | ||
| projectRevealKey && sidebarProjectRevealRequest | ||
| ? { projectKey: projectRevealKey, requestId: sidebarProjectRevealRequest.requestId } | ||
| : null; |
There was a problem hiding this comment.
Mobile reveal stays hidden
Medium Severity
Command palette selections call requestSidebarProjectReveal, but nothing opens the mobile sidebar sheet. On mobile the thread sidebar lives in a closed Sheet with default keepMounted={false}, so project rows are often unmounted and the new scroll-into-view logic cannot run or be seen until the user manually opens the drawer.
Reviewed by Cursor Bugbot for commit d6693a8. Configure here.



Summary
🚀 Mobile Continuous Deploymentlabel.Testing
vp checkvp run typecheckvp run lintvp testNote
Low Risk
Sidebar scrolling and React context only; no auth, data, or API changes.
Overview
When you pick or open a project from the command palette, the sidebar now scrolls that project row into view so it isn’t lost off-screen in a long list.
A reveal request (
projectRef+requestId) is held inCommandPaletteand passed throughcommandPaletteContext(requestSidebarProjectReveal/completeSidebarProjectReveal). Palette flows that target a project—search open, new thread in project, add/browse existing path, and after create—call request before navigation.The sidebar maps the ref to the correct row via
resolveSidebarProjectRevealKey(physical vs grouped logical keys), then the matchingSidebarProjectItemretries withrequestAnimationFrameuntil the header ref exists and callsscrollSidebarProjectIntoView(smooth, centered). Completion clears the request so it doesn’t repeat.Unit tests cover key resolution and scroll options in
sidebarProjectReveal.test.ts.Reviewed by Cursor Bugbot for commit d6693a8. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reveal sidebar projects into view when selected from the command palette
commandPaletteContext.tsxthat lets the command palette signal the sidebar to scroll a specific project into view.requestSidebarProjectRevealis called with the target project ref before navigation.scrollIntoViewwith smooth center positioning viasidebarProjectReveal.ts.completeSidebarProjectRevealcan clear only the matching request once scrolling is done.Macroscope summarized d6693a8.